import { useState } from "react";

function A({ getAName }) {
  const aName = "A";
  return (
    <div>
      this is A<button onClick={() => getAName(aName)}>send</button>
    </div>
  );
}

function B(props) {
  return <div>this is B;{props.name}</div>;
}

function App() {
  const [name, setName] = useState("");
  const getName = (name) => {
    console.log(name);
    setName(name);
  };
  return (
    <div className="App">
      Hello World!
      <A getAName={getName} />
      <B name={name} />
    </div>
  );
}

export default App;
